// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';
import store from './store';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import 'lib-flexible';
import 'px2rem';
import './utils/flexible';
import './utils/px2rem';
import axios from 'axios';
import VueAxios from 'vue-axios';
import * as echarts from 'echarts';
import TreeTable from 'vue-table-with-tree-grid';
import preventReClick from './utils/preventRepeatClick.js';

Vue.prototype.$echarts = echarts;
Vue.use(VueAxios, axios);
Vue.config.productionTip = false;
Vue.use(ElementUI);
Vue.component('tree-table', TreeTable);
Vue.use(preventReClick);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
});

window.addEventListener('popstate', function (e) {
  router.isBack = true;
}, false);
window.addEventListener('storage', function (e) {
  sessionStorage.setItem(e.key, e.oldValue);
});
window.addEventListener('storage', function () {
  sessionStorage.clear();
  window.location.replace('/');
});
